<template>
    <div class="order-components-container">
        <ul class="purchase-order-list">
            <li v-for="(item, index) in listData" :key="index" @click="jumpView(item)">
                <p class="purchase-order-num">订单编号：{{item.outTradeNo}}</p>
                <div class="purchase-order-info-list">
                    <div class="purchase-order-info-list-top">
                        <div class="purchase-order-img">
                            <img :src="item.productSmallPic" alt="">
                        </div>
                        <div class="purchase-order-info-details">
                            <div class="purchase-order-info-detail-item-other">
                                <span>{{item.productSaleType}}{{item.productPostage}}</span>
                                <p>{{item.productName}}</p>
                            </div>
                            <div class="purchase-order-info-detail-item">
                                <span class="product-level">等级：{{item.productLevel}}</span>
                            </div>
                            <div class="purchase-order-info-detail-item weight-package">
                                <span>重量：{{item.productWeight}}{{item.productWeightUnit}}</span>
                                <span>包装：{{item.productPacking}}</span>
                            </div>
                            <div class="purchase-order-info-detail-item">
                                <span>规格：{{item.productSpecs}}</span>
                            </div>
                        </div>
                    </div>
                    <div class="purchase-order-info-list-center">
                        <span>{{item.productSalePrice}}</span>{{item.productSalePriceUnit}}
                    </div>
                </div>
                <div class="purchase-order-info-bottom">
                    <div class="purchase-order-info-bottom-left">
                        <p>共{{item.orderQuantity}}{{item.orderQuantityUnit}}</p>
                        <p>
                            合计：<span>{{item.payMoney}}元</span>
                        </p>
                    </div>

                    <van-button round class="u-bg-gradient-light order-status-btn" v-if="item.state == 0">待付款</van-button>
                    <van-button round class="u-bg-gradient-light order-status-btn" v-if="item.state == 1">待发货</van-button>
                    <van-button round class="u-bg-gradient-light order-status-btn" v-if="item.state == 2">待收货</van-button>
                    <van-button round class="u-bg-gradient-light order-status-btn" v-if="item.state == 3">已完成</van-button>
                    <van-button round class="u-bg-gray order-status-btn" v-if="item.state == 99">已失效</van-button>
                </div>
            </li>
        </ul>
    </div>
</template>

<script>
import Storage from "@/utils/storage";
export default {
    props: ['listData'],
    mounted() {
        Storage.del('count');
        Storage.del('checkedXY');
        Storage.del('checkedZF');
        Storage.del('checkedYE');
    },
    methods: {
        jumpView(item) {
            if(item.state == 0){
                Storage.set('checkedYE', true) // 默认选择 余额支付
                this.$router.push({
                    path: '/helppoor/pot/pay/' + item.id,
                    query: {
                        fromView: 'order',
                        isPot: item.productPacking == '罐装' ? '罐' : '箱'
                    }
                })
                // if(item.productPacking == '罐装'){
				// 	this.$router.push({
				// 		path: '/helppoor/pot/pay/' + item.id,
				// 		query: {
				// 			fromView: 'order'
				// 		}
				// 	})
				// } else if(item.productPacking == '箱装'){
				// 	this.$router.push({
				// 		path: '/helppoor/box/pay/' + item.id,
				// 		query: {
				// 			fromView: 'order'
				// 		}
				// 	})
				// }
            }else{
                this.$router.push({
                    name: 'agaricOrderDetail',
                    query: {
                        orderId: item.id
                    }
                })
            }
        }
    }
}
</script>

<style lang="scss" scoped>
    .order-list-container {
        .purchase-order-list {
            width: 100%;
            padding: 0 16px 10px;
            box-sizing: border-box;
            li {
                width: 100%;
                margin-top: 10px;
                padding: 16px 12px 0;
                box-sizing: border-box;
                border-radius: 8px;
                background-color: #fff;
                .purchase-order-num {
                    margin-bottom: 16px;
                    font-size: 16px;
                    font-weight: 400;
                    color: #344047;
                }
                .purchase-order-info-list {
                    width: 100%;
                    .purchase-order-info-list-top {
                        width: 100%;
                        display: flex;
                        justify-content: space-between;
                        .purchase-order-img {
                            width: 93px;
                            height: 93px;
                            background-color: #f8f8f8;
                            border-radius: 8px;
                            overflow: hidden;
                            img {
                                width: 93px;
                                height: 93px;
                                object-fit: cover;
                            }
                        }
                        .purchase-order-info-details {
                            width: 210px;
                            .purchase-order-info-detail-item {
                                display: flex;
                                justify-content: space-between;
                                align-items: center;
                                margin-top: 8px;
                                color: #969C9E;
                                font-size: 12px;
                                span {
                                    display: block;
                                    // max-width: 50%;
                                }
                                .product-level {
                                    color: #5D6164;
                                }
                            }
                            .weight-package {
                                span {
                                    width: 50%;
                                }
                                span:last-child {
                                    position: relative;
                                    text-align: right;
                                }
                                span:last-child::before {
                                    content: "";
                                    position: absolute;
                                    top: 3px;
                                    left: 0;
                                    width: 1px;
                                    height: 12px;
                                    background-color: #D0CFCF;
                                }
                            }
                            .purchase-order-info-detail-item-other {
                                width: 226px;
                                margin-top: 2px;
                                font-weight: 400;
                                color: #344047;
                                display: flex;
                                span {
                                    position: relative;
                                    width: 64px;
                                    height: 18px;
                                    margin-right: 8px;
                                    border-radius: 100em;
                                    font-size: 12px;
                                    color: #31BC8D;
                                    background-color: #BCEFE3;
                                    text-align: center;
                                }
                                p {
                                    flex: 1;
                                    overflow: hidden;
                                    text-overflow: ellipsis;
                                    white-space: nowrap;
                                }
                            }
                        }
                    }
                    .purchase-order-info-list-center {
                        box-sizing: border-box;
                        margin-top: 6px;
                        margin-bottom: 10px;
                        font-size: 12px;
                        color: #969C9E;
                        text-align: right;
                        span {
                            position: relative;
                            top: 1.5px;
                            margin-right: 6px;
                            font-size: 16px;
                            font-weight: 500;
                            color: #F58523;
                        }
                    }
                    .purchase-order-info-list-bottom {
                        width: 100%;
                        padding: 10px 0;
                        box-sizing: border-box;
                        display: flex;
                        justify-content: space-between;
                        align-items: center;
                        font-size: 12px;
                        color: #969C9E;
                        border-bottom: 1px solid #f2f2f2;
                    }
                }
                .purchase-order-info-bottom {
                    width: 100%;
                    padding: 12px 0;
                    box-sizing: border-box;
                    display: flex;
                    justify-content: space-between;
                    align-items: center;
                    border-top: 1px solid #f2f2f2;
                    .purchase-order-info-bottom-left {
                        display: flex;
                        flex-direction: column;
                        flex: 1;
                        font-weight: 400;
                        p:first-child {
                            margin-bottom: 2px;
                        }
                        p:last-child {
                            span {
                                font-size: 16px;
                            }
                        }
                    }
                    .order-status-btn {
                        width: 88px;
                        height: 34px;
                        line-height: 34px;
                        margin-left: 20px;
                        box-shadow: none;
                        font-size: 14px;
                        color: #fff;
                        border: none;
                    }
                    .order-status-cancel {
                        color: #969C9E;
                        border: 1px solid #969C9E;
                    }
                    .order-status-text {
                        width: 88px;
                        height: 34px;
                        line-height: 34px;
                        margin-left: 20px;
                        font-size: 16px;
                        text-align: right;
                    }
                }
            }
        }
    }
</style>